import axios from 'axios'
import { Toast } from 'vant'

axios.defaults.baseURL = 'http://www.520gongfu.com:9527/api'


// /api/home/sliders

export  const getSliders= (callback) =>{
    axios.get('/home/sliders').then((res) =>{
        callback  &&  callback(res.data)
    })
    .catch((err) =>{
        console.log(err);
    })
}


export const getCategry = (callback) =>{
    axios.get('/home/category').then((res) =>{
        callback && callback(res.data)
    })
    .catch((err) =>{
        console.log(err);
    })
}

export const getFloorlist = (callback) =>{
    axios.get('/home/floorlist').then((res) =>{
        callback && callback(res.data)
    })
    .catch((err) =>{
        console.log(err);
    })
}

export const getdata = (callback) =>{
    axios.get("/category/data").then((res) =>{
        callback && callback(res.data)
    })
    .catch((res) =>{
        console.log(err);
    })
}

export const getproductlist = (params) => {
         return axios
           .get("/product/list",{params})
           .then(res => {
               const {data} = res
               if(data.status == 0){
                   return data.data
               }else{
                   Toast.fail(data.msg)
               }
           })
           .catch((res) => {
             console.log(err);
           });
       };